package com.example.web.controller;

import com.example.common.Interface.cart.entity.dto.*;
import com.example.common.Interface.cart.service.CartService;
import com.example.common.response.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/cart")
public class CartController {
    @DubboReference(check = false)
    private CartService CartService;
    @PostMapping("/add")
    public ResponseResult<AddItemRespDTO> addItem(@RequestBody AddItemReqDTO request) {
        return ResponseResult.success(CartService.addItem(request));
    }
    @PostMapping("/get")
    public ResponseResult<GetCartRespDTO> getCart(@RequestBody GetCartReqDTO request) {
        return ResponseResult.success(CartService.getCart(request));
    }
    @PostMapping("/empty")
    public ResponseResult<EmptyCartRespDTO> emptyCart(@RequestBody EmptyCartReqDTO request) {
        return ResponseResult.success(CartService.emptyCart(request));
    }

}
